// tx/record/record.js
let App = getApp();
var that;
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		list: [],
		money: '',
		isdata:false,
    datacard:'',
    bank_username:'',
    id_card:'',
    bank_name:'',
    card_type:'',
    card_no:''
	},
  userBankInfo() {
    that = this;
    wx.request({
      url: App.url.requestUrl + 'user/userBankInfo',
      method: 'POST',
      header: { 'content-type': 'application/x-www-form-urlencoded', "token": wx.getStorageSync('access_token') },
      dataType: 'json',
      success: function (res) {
        if (res.data.ret == 200) {
          console.log(res.data.data)
          that.setData({
            datacard: res.data.data,
            bank_username: res.data.data.bank_username,
            id_card: res.data.data.id_card,
            bank_name: res.data.data.bank_name,
            card_type: res.data.data.card_type,
            card_no: res.data.data.card_no,


          })
        } else {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          })
        }
      }
    })
  },
  //提现列表
	putforwordList(page) {
		that = this
		wx.request({
			url: App.url.requestUrl + 'user/putforwordList',
			method: 'POST',
			 header: {'content-type': 'application/x-www-form-urlencoded',"token":wx.getStorageSync('access_token')},
			dataType: 'json',
			data: {
				page: page
			},
			success: function(res) {
				if (res.data.ret == 200) {
					if (res.data.data.length>0) {
						that.setData({
							list: res.data.data,
							isdata: false
						})
					}else{
						that.setData({
							list: [],
							isdata: true
						})
					}
				}
			}
		})
	},
	// 申请提现
	applyPut() {
		that = this
		wx.request({
			url: App.url.requestUrl + 'user/applyForword',
			method: 'POST',
			 header: {'content-type': 'application/x-www-form-urlencoded',"token":wx.getStorageSync('access_token')},
			dataType: 'json',
			success: function(res) {
				if (res.data.ret == 200) {
					wx.showToast({
						title: '提现成功',
						icon: 'success',
						duration: 2000
					})
					// 跳转到订单展示界面
					setTimeout(function() {
						wx.navigateTo({
							url: '../../member/index/index',
						})
					}, 2500)

				} else {
					wx.showToast({
						title: res.data.msg,
						icon: 'none',
						duration: 2000
					})
				}
			}
		})
	},
  //提交申请
  // applyPut() {
  //   that = this;
  //   wx.request({
  //     url: App.url.requestUrl + 'user/applyPut',
  //     method: 'POST',
  //     header: { 'content-type': 'application/x-www-form-urlencoded', "token": wx.getStorageSync('access_token') },
  //     dataType: 'json',
  //     data: {
  //       bank_username: that.data.bank_username,
  //       id_card: that.data.id_card,
  //       bank_name: that.data.bank_name,
  //       card_no: that.data.card_no,
  //       card_type: that.data.card_type
  //     },
  //     success: function (res) {
  //       if (res.data.ret == 200) {
  //         wx.showToast({
  //           title: res.data.msg,
  //           icon: 'success',
  //           duration: 2000
  //         })
  //       } else {
  //         wx.showToast({
  //           title: res.data.msg,
  //           icon: 'none',
  //           duration: 2000
  //         })
  //       }
  //     }
  //   })
  // },
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		that = this
		that.setData({
			money: options.money
		})
		that.putforwordList(1)
    that.userBankInfo()
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
